package com.hp.mapper;

import com.hp.entity.Apply;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ApplyMapper {

    //    ## 1.查询所有的运动员信息
    @Select("SELECT applyId id,NAME,age,class className,game FROM apply_info")
    List<Apply> getAll();

    //## 2.根据编号查询运动员信息
    @Select("SELECT applyId id,NAME,age,class className,game FROM apply_info where applyId = #{id}")
    Apply getById(int id);

    //## 3.根据名字模糊，并且根据运动项目查询
    @Select("SELECT applyId id,NAME,age,class className,game FROM apply_info where name like '%${name}%' and game=#{game}")
    List<Apply> getByGame(Apply apply);

    //## 4.添加信息
    @Insert("INSERT INTO apply_info VALUES(NULL,#{name},#{age},#{className},#{game})")
    void addApply(Apply apply);

    //## 5.根据编号修改信息
    @Update("UPDATE apply_info set NAME =#{name},age =#{age},class=#{className},game = #{game} WHERE applyId = #{id}")
    void updateApply(Apply apply);

    //## 6.根据编号删除信息
    @Delete("DELETE FROM apply_info WHERE applyId = #{id} ")
    void delApply(int id);

}
